const { defineConfig } = require('@vue/cli-service')
const { codeInspectorPlugin } = require('code-inspector-plugin')
const WindiCSSWebpackPlugin = require('windicss-webpack-plugin')

module.exports = defineConfig({
  transpileDependencies: true,
  lintOnSave: false, // 关闭eslint
  chainWebpack: (config) => {
    config.plugin('WindiCSSWebpackPlugin').use(WindiCSSWebpackPlugin)
    config.externals({
      axios: 'axios'
    })
    config.cache({
      type: 'filesystem'
    })

    config.plugin('code-inspector-plugin').use(
      codeInspectorPlugin({
        bundler: 'webpack'
      })
    )

    // 代码 gzip
    if (process.env.VUE_APP_BASE_API === 'imuyuan.com') {
      config.plugin('CompressionPlugin').use('compression-webpack-plugin', [
        {
          algorithm: 'gzip',
          cache: false,
          test: productionGzipExtensions,
          threshold: 10240,
          minRatio: 0.8
        }
      ])
    }

    // 添加源映射配置
    config.devtool('source-map'); // 启用源映射
  },
  css: {
    //查看CSS属于哪个css文件
    sourceMap: true,
  },
})
